var editWallDoorArr = [];
$(function () {
  //墙门管理 打开窗口
  $('.wallDoor-trigger').on('click', function (event) {
    event.preventDefault();
    $('.wallDoor-pop').addClass('is-visible3');
    $('#wallDoorModal input').val('');
    $("#wallDoorTableSelectAll").prop("checked", false);
    // 楼宇详情页面 的所属街道
    var ret = getOrganizationList();
    ret
      .then(function (data) {
        console.log(data);
        $('#wallDoorModal .wallDoorSelect').html('<option value="">全部</option>');
        for (var i = 0; i < data.data.length; i++) {
          $('#wallDoorModal .wallDoorSelect').append(
            '<option value="' +
            data.data[i].id +
            '">' +
            data.data[i].orgName +
            '</option>'
          );
        }
        $('#wallDoorModal .wallDoorSelect').val('');
        wallDoorPageList(1);
      })
      .catch(function (err) {
        console.log(err);
      });
  });
  //墙门管理 关闭窗口
  $('.wallDoor-pop').on('click', function (event) {
    if (
      $(event.target).is('.cd-popup-close') ||
      $(event.target).is('.wallDoor-pop')
    ) {
      event.preventDefault();
      $(this).removeClass('is-visible3');
      $('#wallDoorPageBox input').val('');
    }
  });

  // 全选 反选
  $('#wallDoorTableSelectAll').on('click', function () {
    var allcheck = $('#wallDoorTableSelectAll').prop('checked');
    $('#wallDoorModal tbody .check').prop('checked', allcheck);
  });
  // 反选
  $('#wallDoorModal tbody').on('click', '.check', function () {
    var length1 = $('#wallDoorModal tbody').find(':checkbox').length;
    var length2 = $('#wallDoorModal tbody').find(':checked').length;
    if (length1 == length2) {
      $('#wallDoorTableSelectAll').prop('checked', true);
    } else {
      $('#wallDoorTableSelectAll').prop('checked', false);
    }
  });
  //  删除墙门
  $('#wallDoorDelBtn').on('click', function () {
    if ($('#wallDoorModal tbody input[type=checkbox]:checked').length > 0) {
      $('#wallDoorDelBox').addClass('is-visible3');
    }
  });
  //  删除墙门
  $('#wallDoorDelBox .delConfirm').on('click', function () {
    $('#wallDoorModal tbody input[type=checkbox]:checked').each(function () {
      var thisid = $(this).attr('thisid');
      var obj = {};
      obj.id = thisid;
      jsonData = JSON.stringify(obj);
      $.ajax({
        url: '/wallDoor/del?id=' + thisid,
        type: 'delete',
        data: jsonData,
        contentType: 'application/json',
        async: false,
        success: function (res) {
          console.log(res);
        }
      });
    });
    if ($('#wallDoorTableSelectAll').prop('checked')) {
      wallDoorPage = wallDoorPage - 1;
      if (wallDoorPage < 1) {
        wallDoorPage = 1;
      }
    }
    wallDoorPageList(wallDoorPage);
    // 微型消防站管理 获取总页数 点击分页渲染列表
    wallDoorPageFunc(wallDoorPage);
    $('#wallDoorTableSelectAll').prop('checked', false);
    tipModalFunc('删除成功!');
    $('#wallDoorDelBox').removeClass('is-visible3');
  });
  var wallDoorPage = 1;
  var wallDoorPageNum = 1;
  // 老墙门分页
  function wallDoorPageFunc(pageSum, startPageNum) {
    console.log(pageSum);
    if (pageSum <= 1) {
      $('#wallDoorPageBox .pageJump').hide();
    } else {
      $('#wallDoorPageBox .pageJump').show();
    }
    Page({
      num: pageSum, //页码数
      startnum: startPageNum, //指定页码
      elem: $('#wallDoorPage'), //指定的元素
      callback: function (n) {
        //回调函数
        console.log(n);
        wallDoorPage = n;
        wallDoorPageList(n);
        // 当翻到下一页时 清除掉 全选按钮的 选中状态
        $('#wallDoorTableSelectAll').prop('checked', false);
      }
    });
  }
  // 渲染 墙门 列表
  function wallDoorPageList(n) {
    //hasExpired 是否过期 (true过期 false未过期)
    $('#wallDoorModal .tableBox tbody').html('');
    var page = n - 1;
    var size = 10;
    var searchAddress = $('#wallDoorModal .wallDoorSearchInput').val();
    var wallDoorSelect = $('#wallDoorModal .wallDoorSelect').val();
    wallDoorSelect = wallDoorSelect ? wallDoorSelect : '';
    // 获取墙门列表 http://127.0.0.1:9092/wallDoor/getList?address=2&orgId=66&page=0&size=10
    $.ajax({
      url: '/wallDoor/getList?page=' +
        page +
        '&size=' +
        size +
        '&address=' +
        searchAddress +
        '&orgId=' +
        wallDoorSelect,
      success: function (res) {
        console.log(res);
        if (res.status == 200) {
          wallDoorPageNum = res.data.totalPages;
          var data = res.data.content;
          editWallDoorArr = data;
          console.log(editWallDoorArr);
          var size = res.data.size;
          for (var i = 0; i < data.length; i++) {
            var address = data[i].address;

            // if (address.length > 35) {
            //   address = address.slice(0, 35) + ' . . .';
            // }
            // 35字
            $('#wallDoorModal .tableBox tbody').append(
              `<tr>
            <td><input type="checkbox" class="check" thisid="` +
              data[i].id +
              `"/></td>
            <td>` +
              ((n - 1) * size + i + 1) +
              `</td>
            <td>` +
              address +
              `</td>
            <td>` +
              data[i].org.orgName +
              `</td>
            <td>` +
              data[i].personNum +
              `</td>
            <td>` +
              data[i].emergencyPeople +
              `</td>
            <td>` +
              data[i].emergencyPhone +
              `</td>
            <td longitude="` + data[i].longitude + `" latitude="` + data[i].latitude + `">
              <span class="seeBtnStyle editWallDoor-trigger" index="` +
              i +
              `" thisid="` +
              data[i].id +
              `">查看详情</span>
              <span class="positionBtn wallDoorPositionBtn">定位</span>
            </td>
          </tr>`
            );
          }
          wallDoorPageFunc(wallDoorPageNum, n);
        }
      }
    });
  }
  buildSearchFunc();
  // 按照老墙门地址模糊搜索
  function buildSearchFunc() {
    //模糊查询
    $('body').on('click', function () {
      $('#wallDoorModal .searchList').hide();
    });
    var fn = _.debounce(function () {
      $('#wallDoorModal .searchList').show();

      if ($('#wallDoorModal .searchList li')) {
        //键盘抬起后就判断页面中是否存在这个元素,存在就删除
        $('#wallDoorModal .searchList li').remove();
      }
      buildSearchContent = $('#wallDoorModal .wallDoorSearchInput').val();
      buildSearchContent = $.trim(buildSearchContent);
      console.log(buildSearchContent);
      if (buildSearchContent) {
        $.ajax({
          url: '/wallDoor/findLikeByAddress?address=' + buildSearchContent,
          type: 'GET',
          async: false,
          success: function (result) {
            console.log(result);
            var data = result.data;
            for (var i = 0; i < data.length; i++) {
              $('#wallDoorModal .searchList').append(
                '<li>' + data[i] + '</li>'
              );
            }
          }
        });
        $('#wallDoorModal .searchList').show();
      }
    }, 500);
    $('#wallDoorModal .wallDoorSearchInput').on('input', function (e) {
      fn();
    });
    //直接输入地址,点击列表查询
    $('#wallDoorModal .searchList').on('click', 'li', function () {
      $('#wallDoorModal .searchList').show();
      var liVal = $(this).text();
      liVal = $.trim(liVal);
      var searchVal = $('#wallDoorModal .wallDoorSearchInput').val(liVal);
      buildSearchContent = liVal;
      $('#wallDoorModal .searchList').html(''); //hide
      return false;
    });
  }
  // 点击搜索，查询
  $('#wallDoorSearchBtn').click(function () {
    wallDoorPageList(1);
    $('#wallDoorPageBox input').val('');
    $('#wallDoorTableSelectAll').prop('checked', false);
  });

  //    墙门添加
  // $('.addWallDoor-pop').addClass('is-visible3');
  //墙门管理添加 打开窗口
  $('.addWallDoor-trigger').on('click', function (event) {
    event.preventDefault();
    $('.addWallDoor-pop').addClass('is-visible3');
  });
  //墙门管理添加 关闭窗口
  $('.addWallDoor-pop').on('click', function (event) {
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.addWallDoor-pop')) {

      event.preventDefault();
      $(this).removeClass('is-visible3');
      clearAddWallDoor();
    }
  });

  function getObjectURL(file) {
    var url = null;
    if (window.createObjectURL != undefined) {
      // basic
      url = window.createObjectURL(file);
    } else if (window.URL != undefined) {
      // mozilla(firefox)
      url = window.URL.createObjectURL(file);
    } else if (window.webkitURL != undefined) {
      // webkit or chrome
      url = window.webkitURL.createObjectURL(file);
    }
    return url;
  }

  // 人员添加 点击上传图片到本地
  $('#addWallDoorForm .touxiang').on('click', '.pic', function () {
    $(this)
      .parent()
      .find('.upload')
      .click(); //隐藏了input:file样式后，点击头像就可以本地上传
    $(this)
      .parent()
      .find('.upload')
      .on('change', function (e) {
        var objUrl = getObjectURL(this.files[0]); //获取图片的路径，该路径不是图片在本地的路径
        if (objUrl) {
          $(this)
            .parent()
            .find('.pic')
            .attr('src', objUrl);
          $(this)
            .parent()
            .find('.pic')
            .removeClass('opacity0');
        } else {
          $(this)
            .parent()
            .find('.pic')
            .addClass('opacity0');
        }
      });
  });
  // 人员信息 添加页面的 删除头像
  $('#addWallDoorForm .delTouxiang').on('click', function () {
    $(this)
      .siblings('.pic')
      .attr('src', '');
    $('#addWallDoorForm .pic').addClass('opacity0');
    $('#addWallDoorForm .upload').val('');

  });
  // 楼宇详情页面 的所属街道
  var ret = getOrganizationList();
  ret
    .then(function (data) {
      console.log(data);
      $('#addWallDoorForm .bMInfoAddPageFormOrgList').html('');
      for (var i = 0; i < data.data.length; i++) {
        $('#addWallDoorForm .bMInfoAddPageFormOrgList').append(
          '<option value="' +
          data.data[i].id +
          '">' +
          data.data[i].orgName +
          '</option>'
        );
      }
      $('#addWallDoorForm .bMInfoAddPageFormOrgList').val(data.data[0].id);
    })
    .catch(function (err) {
      console.log(err);
    });

  // 墙门添加
  addWallDoorFormValidator();

  function addWallDoorFormValidator() {
    $('#addWallDoorForm')
      .bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
          valid: 'glyphicon glyphicon-ok',
          invalid: 'glyphicon glyphicon-remove',
          validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
          address: {
            validators: {
              notEmpty: {
                message: '墙门地址不能为空'
              }
            }
          },
          personNum: {
            validators: {
              notEmpty: {
                message: '墙门内户数不能为空'
              },
              regexp: {
                regexp: /^[0-9]*$/,
                message: '墙门内户数只能包含数字'
              }
            }
          },
          emergencyPeople: {
            validators: {
              notEmpty: {
                message: '联系人不能为空'
              }
            }
          },
          emergencyPhone: {
            validators: {
              notEmpty: {
                message: '联系电话不能为空'
              },
              regexp: {
                regexp: /^[0-9]*$/,
                message: '联系电话只能包含数字'
              }
            }
          },
          longitude: {
            validators: {
              notEmpty: {
                message: '经度不能为空'
              }
            }
          },
          latitude: {
            validators: {
              notEmpty: {
                message: '纬度不能为空'
              }
            }
          },
          orgId: {
            validators: {
              notEmpty: {
                message: '所属街道不能为空'
              }
            }
          }
        }
      })
      .on('success.form.bv', function (e) {
        e.preventDefault();

        // var orgId = $("#addWallDoorForm .bMInfoAddPageFormOrgList").val();
        var $form = $(e.target);
        var imgUrl = $('#addWallDoorForm .touxiang img').attr('src');

        // var buildWorkRangeArrSub = [];
        // for (var i = 0; i < buildWorkRangeArr.length; i++) {
        //   var buildWorkRangeObjSub = {};
        //   buildWorkRangeObjSub.id = buildWorkRangeArr[i].id;
        //   console.log(i, buildWorkRangeArr[i].id)
        //   buildWorkRangeArrSub.push(buildWorkRangeObjSub);
        // }
        console.log(imgUrl);
        if (imgUrl) {
          var obj = new FormData($form[0]);

          // obj.append("workingRange", JSON.stringify(buildWorkRangeArrSub));
          console.log($form.serialize());
          // +'?workingRange='+buildWorkRangeArr
          $.ajax({
            url: '/wallDoor/save',
            type: 'POST',
            async: false,
            data: obj,
            contentType: false,
            processData: false,
            success: function (result) {
              console.log(result);
              if (result.status == 200) {
                $('.addWallDoor-pop').removeClass('is-visible3');
                tipModalFunc('添加成功!');
                wallDoorPageList(wallDoorPage);
                // 添加成功后重新渲染

                // buildingPersonPageList(buildingPersonNumCurr, personSearchContent);
                //Modal验证销毁重构
                $('#addWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#addWallDoorForm').data('bootstrapValidator', null);
                // // 清空数据
                $('#addWallDoorForm')
                  .find('input')
                  .val('');
                $('#addWallDoorForm .pic').attr('src', '');
                addWallDoorFormValidator();
              } else {
                console.log(result.message);
                $('#addWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#addWallDoorForm').data('bootstrapValidator', null);

                $('#addWallDoorForm .pic').attr('src', '');
                addWallDoorFormValidator();
              }
            },
            error: function () {
              $('#addWallDoorForm')
                .data('bootstrapValidator')
                .destroy();
              $('#addWallDoorForm').data('bootstrapValidator', null);

              $('#addWallDoorForm .pic').attr('src', '');
              addWallDoorFormValidator();
            }
          });
        } else {
          var obj = $form.serialize();
          console.log(obj);
          $.ajax({
            url: '/wallDoor/save',
            type: 'POST',
            async: false,
            data: obj,
            success: function (result) {
              console.log(result);
              if (result.status == 200) {
                $('.addWallDoor-pop').removeClass('is-visible3');
                tipModalFunc('添加成功!');
                wallDoorPageList(wallDoorPage);
                // 添加成功后重新渲染
                // buildingPersonPageList(buildingPersonNumCurr, personSearchContent);
                //Modal验证销毁重构
                $('#addWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#addWallDoorForm').data('bootstrapValidator', null);

                $('#addWallDoorForm .pic').attr('src', '');
                // 清空数据
                $('#addWallDoorForm')
                  .find('input')
                  .val('');
                addWallDoorFormValidator();
              } else {
                console.log(result.message);
                $('#addWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#addWallDoorForm').data('bootstrapValidator', null);

                $('#addWallDoorForm .pic').attr('src', '');
                addWallDoorFormValidator();
              }
            },
            error: function () {
              $('#addWallDoorForm')
                .data('bootstrapValidator')
                .destroy();
              $('#addWallDoorForm').data('bootstrapValidator', null);

              $('#addWallDoorForm .pic').attr('src', '');
              addWallDoorFormValidator();
            }
          });
        }
      });
  }

  var delTouxiangFlag = false;
  // 点击修改时,可以修改编辑
  $('#editWallDoorForm .allowEdit').on('click', function () {
    delTouxiangFlag = true;
    $('#editWallDoorForm .allowEdit').hide();
    $('#editWallDoorBtn').show();
    $('#editWallDoorForm input').removeAttr('disabled');
    $('#editWallDoorForm select').removeAttr('disabled');
    $('#editWallDoorForm select').removeClass('disabledStyle');
    $('#editWallDoorForm input').removeClass('disabledStyle');
  });
  // 删除楼宇详情的图片
  $('#editWallDoorForm .delTouxiang').on('click', function () {
    if (delTouxiangFlag) {
      $(this)
        .siblings('.pic')
        .attr('src', '');
      $('#editWallDoorForm .pic').addClass('opacity0');
      $('#editWallDoorForm .upload').val('');
      $('#editWallDoorForm .oldPhoto').val('');
    }
  });

  // 清空墙门添加数据
  function clearAddWallDoor() {
    //Modal验证销毁重构
    $('#addWallDoorForm')
      .data('bootstrapValidator')
      .destroy();
    $('#addWallDoorForm').data('bootstrapValidator', null);
    // // 清空数据
    $('#addWallDoorForm')
      .find('input')
      .val('');
    $('#addWallDoorForm .pic').attr('src', '');
    $('#addWallDoorForm .pic').addClass('opacity0');
    addWallDoorFormValidator();
  }

  var wallDoorIndex = '';
  //墙门管理修改 打开窗口
  $('#wallDoorModal').on('click', '.editWallDoor-trigger', function (event) {
    event.preventDefault();
    $('.editWallDoor-pop').addClass('is-visible3');
    var index = $(this).attr('index');
    wallDoorIndex = index;
    var arr = editWallDoorArr[index];
    console.log(arr);

    $('#editWallDoorForm .editWallDoorImg img').attr('src', arr.photoUrl);
    $('#editWallDoorForm .address').val(arr.address);
    $('#editWallDoorForm .personNum').val(arr.personNum);
    $('#editWallDoorForm .emergencyPeople').val(arr.emergencyPeople);
    $('#editWallDoorForm .emergencyPhone').val(arr.emergencyPhone);
    $('#editWallDoorForm .longitude').val(arr.longitude);
    $('#editWallDoorForm .latitude').val(arr.latitude);
    if (arr.photoUrl) {
      $('#editWallDoorForm .touxiang .pic').removeClass('opacity0');
      $('#editWallDoorForm .oldPhoto').val(arr.photoUrl);
    } else {
      $('#editWallDoorForm .touxiang .pic').addClass('opacity0');
    }
    // 楼宇详情页面 的所属街道
    var ret = getOrganizationList();
    ret
      .then(function (data) {
        console.log(data);
        $('#editWallDoorForm .bMInfoAddPageFormOrgList').html('');
        for (var i = 0; i < data.data.length; i++) {
          $('#editWallDoorForm .bMInfoAddPageFormOrgList').append(
            '<option value="' +
            data.data[i].id +
            '">' +
            data.data[i].orgName +
            '</option>'
          );
        }
        $('#editWallDoorForm .bMInfoAddPageFormOrgList').val(arr.org.id);
      })
      .catch(function (err) {
        console.log(err);
      });
    // 点击查看详情时，只查看不修改
    $('#editWallDoorForm input').attr('disabled', 'disabled');
    $('#editWallDoorForm select').attr('disabled', 'disabled');
    $('#editWallDoorForm select').addClass('disabledStyle');
    $('#editWallDoorForm input').addClass('disabledStyle');
    delTouxiangFlag = false;
    $('#editWallDoorForm .allowEdit').show();
    $('#editWallDoorBtn').hide();
  });

  // 修改老墙门图片
  $('#editWallDoorForm .editWallDoorImg').on('click', '.pic', function () {
    console.log(this);
    $(this)
      .parent()
      .find('.upload')
      .click(); //隐藏了input:file样式后，点击头像就可以本地上传
    $(this)
      .parent()
      .find('.upload')
      .on('change', function (e) {
        console.log(this.files[0]);
        var objUrl = getObjectURL(this.files[0]); //获取图片的路径，该路径不是图片在本地的路径
        console.log(objUrl);
        picThat = this;
        console.log(this);
        if (objUrl) {
          $(this)
            .parent()
            .find('.pic')
            .attr('src', objUrl);
          $(this)
            .parent()
            .find('.pic')
            .removeClass('opacity0');
        } else {
          $(this)
            .parent()
            .find('.pic')
            .addClass('opacity0');
        }
      });
  });
  // 修改墙门
  editWallDoorFormValidator();

  function editWallDoorFormValidator() {
    $('#editWallDoorForm')
      .bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
          valid: 'glyphicon glyphicon-ok',
          invalid: 'glyphicon glyphicon-remove',
          validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
          address: {
            validators: {
              notEmpty: {
                message: '墙门地址不能为空'
              }
            }
          },
          personNum: {
            validators: {
              notEmpty: {
                message: '墙门内户数不能为空'
              },
              regexp: {
                regexp: /^[0-9]*$/,
                message: '墙门内户数只能包含数字'
              }
            }
          },
          emergencyPeople: {
            validators: {
              notEmpty: {
                message: '联系人不能为空'
              }
            }
          },
          emergencyPhone: {
            validators: {
              notEmpty: {
                message: '联系电话不能为空'
              },
              regexp: {
                regexp: /^[0-9]*$/,
                message: '联系电话只能包含数字'
              }
            }
          },
          longitude: {
            validators: {
              notEmpty: {
                message: '经度不能为空'
              }
            }
          },
          latitude: {
            validators: {
              notEmpty: {
                message: '纬度不能为空'
              }
            }
          },
          orgId: {
            validators: {
              notEmpty: {
                message: '所属街道不能为空'
              }
            }
          }
        }
      })
      .on('success.form.bv', function (e) {
        e.preventDefault();
        var $form = $(e.target);
        var imgUrl = $('#editWallDoorForm .touxiang img').attr('src');
        console.log(imgUrl);

        var id = editWallDoorArr[wallDoorIndex].id;
        var oldPhoto = $('#editWallDoorForm .oldPhoto').val();
        var newPhoto = $('#editWallDoorForm .touxiang img').attr('src');
        console.log(oldPhoto, newPhoto, oldPhoto == newPhoto);

        if (oldPhoto != newPhoto && newPhoto != '') {
          var obj = new FormData($form[0]);
          // obj.id = id;
          console.log($form.serialize());
          $.ajax({
            url: '/wallDoor/save?id=' + id,
            type: 'POST',
            async: false,
            data: obj,
            contentType: false,
            processData: false,
            success: function (result) {
              console.log(result);
              if (result.status == 200) {
                $('.editWallDoor-pop').removeClass('is-visible3');
                tipModalFunc('修改成功!');
                wallDoorPageList(wallDoorPage);
                //Modal验证销毁重构
                $('#editWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#editWallDoorForm').data('bootstrapValidator', null);
                // // 清空数据
                $('#editWallDoorForm')
                  .find('input')
                  .val('');
                $('#editWallDoorForm .pic').attr('src', '');
                editWallDoorFormValidator();
              } else {
                console.log(result.message);
                $('#editWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#editWallDoorForm').data('bootstrapValidator', null);

                $('#editWallDoorForm .pic').attr('src', '');
                editWallDoorFormValidator();
              }
            },
            error: function () {
              $('#editWallDoorForm')
                .data('bootstrapValidator')
                .destroy();
              $('#editWallDoorForm').data('bootstrapValidator', null);

              $('#editWallDoorForm .pic').attr('src', '');
              editWallDoorFormValidator();
            }
          });
        } else {
          var obj = $form.serialize();
          obj = obj + '&photoUrl=' + oldPhoto + '&id=' + id;

          console.log(obj);
          $.ajax({
            url: '/wallDoor/save',
            type: 'POST',
            async: false,
            data: obj,
            success: function (result) {
              console.log(result);
              if (result.status == 200) {
                $('.editWallDoor-pop').removeClass('is-visible3');
                tipModalFunc('修改成功!');
                wallDoorPageList(wallDoorPage);
                //Modal验证销毁重构
                $('#editWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#editWallDoorForm').data('bootstrapValidator', null);

                $('#editWallDoorForm .pic').attr('src', '');
                // 清空数据
                $('#editWallDoorForm')
                  .find('input')
                  .val('');
                editWallDoorFormValidator();
              } else {
                console.log(result.message);
                $('#editWallDoorForm')
                  .data('bootstrapValidator')
                  .destroy();
                $('#editWallDoorForm').data('bootstrapValidator', null);

                $('#editWallDoorForm .pic').attr('src', '');
                editWallDoorFormValidator();
              }
            },
            error: function () {
              $('#editWallDoorForm')
                .data('bootstrapValidator')
                .destroy();
              $('#editWallDoorForm').data('bootstrapValidator', null);

              $('#editWallDoorForm .pic').attr('src', '');
              editWallDoorFormValidator();
            }
          });
        }
      });
  }
  //墙门管理修改 关闭窗口
  $('.editWallDoor-pop').on('click', function (event) {
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.editWallDoor-pop')) {
      event.preventDefault();
      $(this).removeClass('is-visible3');
      clearEditWallDoor();
    }
  });

  // 清空墙门编辑数据
  function clearEditWallDoor() {
    $('#wallDoorContentEdit').val('');
    $('#editWallDoorForm .oldPhoto').val('');
  }
});